﻿<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="Pragma" content="no-cache">
<link rel="STYLESHEET" type="text/css" id="SkinStyleSheet">
<title>WebNoteEditor</title>
<script language="javascript" type="text/javascript" src="../script/windialog.js"></script>
<script language="javascript" type="text/javascript" src="../script/ie2w3c-min.js"></script>

<script language="javascript" type="text/javascript">
window.onload=function()
{
	renderWindowAsIE(window);
	try
	{
		WebNoteEx.window2=window;
		var version=WebNoteEx.Version().right(6);
		//alert(version);
	}
	catch(e)
	{
		if (confirm(EditorWindow.lang_text_ask_setupword2pictureactivex))
		{
			EditorWindow.__setupActiveX();
			window.close();
		}
	}
	AutoResizeDialogWindow();
}

function __btnOk_onclick()
{

	var extName;
	if (document.getElementById("wordfilepath").value.trim()=="")
	{
		alert(EditorWindow.lang_pleaseselectdocfile);
		return;
	}
	extName=EditorWindow.getFileExt(document.getElementById("wordfilepath").value.trim());
	if (extName!="doc" && extName!="docx")
	{
		alert(EditorWindow.lang_pleaseselectdocfile);
		return;
	}

	var outType=EditorWindow._FormgetRadioValue("chk_fileType",document);

	
	if (outType=="html")
	{
		document.getElementById("btnOk").disabled=true;
		WebNoteEx.OpenWordFile(document.getElementById("wordfilepath").value);
		
		if (EditorWindow.WebNoteCanPageSplit)
		{
			var i,fileName=EditorWindow.getFileName(document.getElementById("wordfilepath").value).replace("\."+extName,"");
			var elem=EditorWindow.document.getElementById("AbsolutePage");
			var length=elem.options.length;
			for (i=0;i<length;i++)
			{
				elem.options[0].innerHTML="";
				elem.options[0].removeNode();
			}

			XEditor.document.body.setAttribute("absolutepage","0");
			for (i=1;i<=WebNoteEx.PageCount;i++)
			{
				EditorWindow.NewPage();
				EditorWindow.gotoAbsolutePage(i);
				EditorWindow.setHTML("");
				
				WebNoteEx.WordPageToClipboard(i);
				EditorWindow.create("paste");
				EditorWindow._XeditorEvent_onafterpaste();
				
				elem.options(i-1).setAttribute("pagetitle",fileName+"(page_"+i+")");
				elem.options(i-1).setAttribute("html",EditorWindow.getHTML());
				EditorWindow.document.getElementById("pagetitle").value=elem.options[i-1].getAttribute("pagetitle");
			}
			elem=null;
		}
		else
		{
			
			WebNoteEx.WordWholeToClipboard();
			EditorWindow.create("paste");
			EditorWindow._XeditorEvent_onafterpaste();
		}
		
		WebNoteEx.CloseWord();

		//if err.Description<>"" then
		//	alert err.Description
		//end if
	}
	else
	{
		var DistinctName=EditorWindow.getAutoName();
		WebNoteEx.DistinctName=DistinctName;
		document.getElementById("btnOk").disabled=true;
		var PageCount=WebNoteEx.Word2Picture(document.getElementById("wordfilepath").value,outType);
		//var papersize=webNoteEx.PaperSize;
		var i;
		
		var returnHTML="";
		if (PageCount>=1)
		{
			document.getElementById("btnOk").disabled=false;
			returnHTML="<div class=\"wordtopicture\"><div class=\"wordpictures\">";
			
			for (i=1;i<=PageCount;i++)
			{
				returnHTML+="<img src=\""+WebNoteEx.getTempFolderPath()+"\\"+DistinctName+i+"."+outType+"\" pape=\""+i+"\"><br>";
			}
			returnHTML+="</div></div>";
			EditorWindow.pasteHTML(returnHTML);
		}
		
		EditorWindow._XeditorEvent_onafterpaste();
	}
	
	window.returnValue=true;
	window.close();
}


function __btnCancel_onclick()
{
	window.close();
}
</script>
</head>

<body class="dialog">
<script language="javascript" type="text/javascript">dialogTitle("lang_importworddocument");</script>
<input type="file" id="wordfilepath" style="width:100%">
<div style="clear:both;height:38px">
	<fieldset style="width:180px;float:left;">
	<legend>
		<script language="javascript" type="text/javascript">dialogPrintlang("lang_importwordasnormal");</script>
	</legend>
		<input name="chk_fileType" type="radio" value="html" checked="checked">html
	</fieldset>
	
	<fieldset style="width:200px;float:right;height:38px;">
	<legend>
		<script language="javascript" type="text/javascript">dialogPrintlang("lang_wordtopicture")</script>
	</legend>
		<input name="chk_fileType" type="radio" value="gif">gif
		<input name="chk_fileType" type="radio" value="jpg">jpg
		<input name="chk_fileType" type="radio" value="png">png
	</fieldset>
</div>

<div style="text-align:center;background-color:#ffffff;position:relative;z-index:-1">
	<script language="javascript" type="text/javascript">
		document.write("<object id=\"WebNoteEx\" CLASSID=\"CLSID:"+EditorWindow.$config.WebNoteEx_CLSID+"\"></object>");
	</script>
</div>
<div class="buttons">
	<hr size="1" color="#B3AC9D">
	<script language="javascript" type="text/javascript">
		PrintButtons2();
	</script>
</div>

</body>

</html>
